import { scanCodeTypeObj, scanTableColumns } from './data'

export function useScanColumns() {
  const getScanColumns = (column, record) => {
    if (column.dataIndex === 'productName') {
      return <span>{record.productName}</span>
    } else if (column.dataIndex === 'productNumber') {
      return <span>{record.productNumber}</span>
    } else if (column.dataIndex === 'scanCode') {
      return <span>{record.scanCode}</span>
    } else if (column.dataIndex === 'scanCodeType') {
      let scanCodeTypeStr = ''
      scanCodeTypeObj.forEach(model => {
        if (model.value == record.scanCodeType) {
          scanCodeTypeStr = model.label
        }
      })
      return <span>{scanCodeTypeStr}</span>
    }
  }
  return {
    getScanColumns,
    scanTableColumns
  }
}
